const {
  DataTypes
} = require('sequelize');
module.exports = sequelize => {
  const attributes = {
    userId: {
      type: DataTypes.BIGINT,
      allowNull: false,
      defaultValue: null,
      primaryKey: true,
      autoIncrement: true,
      comment: "用户编号",
      field: "user_id"
    },
    openid: {
      type: DataTypes.STRING(100),
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "从小程序获取用户openid，允许为空",
      field: "openid"
    },
    deviceId: {
      type: DataTypes.STRING(100),
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "从小程序获取用户设备ID，允许为空",
      field: "device_id"
    },
    userName: {
      type: DataTypes.STRING(100),
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "用户名，昵称",
      field: "user_name"
    },
    loginName: {
      type: DataTypes.STRING(100),
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "用户登录名",
      field: "login_name"
    },
    passwd: {
      type: DataTypes.STRING(100),
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "用户登录密码",
      field: "passwd"
    },
    email: {
      type: DataTypes.STRING(100),
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "用户邮件",
      field: "email"
    },
    mobile: {
      type: DataTypes.STRING(100),
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "用户手机号，允许为空",
      field: "mobile"
    },
    userType: {
      type: DataTypes.STRING(10),
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "用户类型",
      field: "user_type"
    },
    isActive: {
      type: DataTypes.INTEGER(6),
      allowNull: true,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "用户是否激活：0 -> 未激活; 1 -> 已激活",
      field: "is_active"
    },
    isAdmin: {
      type: DataTypes.INTEGER(6),
      allowNull: true,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "用户是否管理员：0 -> 否; 1 -> 是",
      field: "is_admin"
    },
    roleId: {
      type: DataTypes.BIGINT,
      allowNull: true,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "角色ID",
      field: "role_id"
    },
    avatar: {
      type: DataTypes.STRING(255),
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "用户自定义头像",
      field: "avatar"
    },
    description: {
      type: DataTypes.TEXT,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "用户简介",
      field: "description"
    },
    userInfo: {
      type: DataTypes.TEXT,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "从小程序授权获取的用户信息",
      field: "user_info"
    }
  };
  const options = {
    tableName: "user",
    comment: "",
    indexes: []
  };
  const UserModel = sequelize.define("userModel", attributes, options);
  return UserModel;
};